package com.zfl.thread.day05;

import java.util.concurrent.CompletableFuture;

public class CompletableFutureDemo04 {
    public static void main(String[] args) {
        CompletableFuture<String> completableFuture1 = CompletableFuture.supplyAsync(()->{
            System.out.println("任务A");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            return "userA";
        });

        CompletableFuture<String> completableFuture2 = CompletableFuture.supplyAsync(() -> {
            System.out.println("任务B");
            return "userB";
        });

        completableFuture1.applyToEither(completableFuture2,v->{
            System.out.println(v+"_over");
            return null;
        });


    }
}
